package com.jimmy.medical.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang.StringUtils;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

/**
 * 商品管理
 */
@Entity
@Table(name = "goods_manage")
public class Commodity extends AbstractEntity {
	
	/**
	 * 商品名字
	 */
	@Column(name="name")
	private String name ;
	
	/**
	 * 所属疾病，通过逗号隔开
	 */
	@Column(name="disease")
	private String disease ;

	/**
	 * 所属疾病，通过逗号隔开
	 */
	@Column(name="disease_cn")
	private String diseaseCn;
	
	/**
	 * 所属会员类型
	 */
	@Column(name="memberType")
	private String memberType ;
	
	/**
	 * 所属会员类型
	 */
	@Column(name="member_type_cn")
	private String memberTypeCn ;
	
	/**
	 * 商品图片
	 */
	@ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "image_id")
    @NotFound(action = NotFoundAction.IGNORE)
	private UploadFile image;
	
	/**
	 * 销量
	 */
	@Column(name="salenum")
	private int salenum ;
	
	/**
	 * 状态：1：发布，0：隐藏
	 */
	@Column(name="state")
	private String state ;
	
	/**
	 * 链接
	 */
	@Column(name="url")
	private String url;
	
	/**
	 * 商品价格
	 */
	@Column(name="price")
	private double price ;
	
	/**
	 * 商品类型
	 */
	@ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "type")
    @NotFound(action = NotFoundAction.IGNORE)
	private SysCode type;

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public String getDiseaseCn() {
		return diseaseCn;
	}

	public void setDiseaseCn(String diseaseCn) {
		this.diseaseCn = diseaseCn;
	}

	public String getMemberTypeCn() {
		return memberTypeCn;
	}

	public void setMemberTypeCn(String memberTypeCn) {
		this.memberTypeCn = memberTypeCn;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDisease() {
		return disease;
	}

	public void setDisease(String disease) {
		this.disease = disease;
	}

	public String getMemberType() {
		return memberType;
	}

	public void setMemberType(String memberType) {
		this.memberType = memberType;
	}

	public UploadFile getImage() {
		return image;
	}

	public void setImage(UploadFile image) {
		this.image = image;
	}

	public int getSalenum() {
		return salenum;
	}

	public void setSalenum(int salenum) {
		this.salenum = salenum;
	}

	public String getState() {
		return state;
	}

	public String getStateCn() {
		if(StringUtils.isNotBlank(state)) {
			if(state.equals("1")) {
				return "正常";
			}
			
			return "隐藏";
		}
		return "未知";
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getUrl() {
		return url;
	}

	public SysCode getType() {
		return type;
	}

	public void setType(SysCode type) {
		this.type = type;
	}

	public void setUrl(String url) {
		this.url = url;
	}
}
